local joy__huangsi = fk.CreateSkill {

  name = "joy__huangsi",

  tags = { Skill.Limited, },

}



joy__huangsi:addEffect(fk.AskForPeaches, {
  name = "joy__huangsi",
  anim_type = "support",
  frequency = Skill.Limited,
  events = {fk.AskForPeaches},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(joy__huangsi.name) and player.dying and player:usedSkillTimes(joy__huangsi.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, joy__huangsi.name, nil, "#joy__huangsi-invoke")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = player:getHandcardNum()
    room:recover({
      who = player,
      num = 1 - player.hp,
      recoverBy = player,
      skillName = joy__huangsi.name
    })
    player:throwAllCards("h")
    if player.dead then return end
    local to = room:askForChoosePlayers(player, table.map(room.alive_players, function(p)
      return p.id end), 1, 1, "#joy__huangsi-choose:::"..(n + 2), joy__huangsi.name, true)
    if #to > 0 then
      room:getPlayerById(to[1]):drawCards(n + 1, joy__huangsi.name)
    end
  end,
})

return joy__huangsi